#ifndef GUI_APPLICATION_H_H_H
#define GUI_APPLICATION_H_H_H
#include <QPixmap>
#include <string>
#include <vector>

#define  putpix()

#include <App_Application.h>

class BaseView;
class CommandManager;

namespace App
{
	class Document;
}
namespace Gui
{
class Gui_Document;
class BaseView;
class ViewProvider;
}

class MDIView;
class MainWindow;



class MenuItem;
class CommandManager;
class Gui_Application
{
public:
	Gui_Application(void);
	virtual~Gui_Application(void);

public:



	void open(const char* FileName, const char* Module);
	/// import a file into the document DocName
	void importFrom(const char* FileName, const char* DocName, const char* Module);
	/// Export objects from the document DocName to a single file
	void exportTo(const char* FileName, const char* DocName, const char* Module);

	Gui::Gui_Document* getDocument(const char* name) const;
    /** Retrieves a pointer to the Gui::Document whose App::Document matches to \a pDoc.
    * If no such document exists 0 is returned.
    */
	Gui::Gui_Document* getDocument(const App::Document* pDoc) const;

	Gui::Gui_Document* getActiveDocument() const;


	bool activateWorkbench(const char* name);
	QPixmap workbenchIcon(const QString&) const;
	QString workbenchToolTip(const QString&) const;
	QString workbenchMenuText(const QString&) const;
	QStringList workbenches(void) const;
	void setupContextMenu(const char* recipient, MenuItem*) const;

	static bool AddDataObject(const char* objName);
	static bool sendMsgToActiveView(const char* pMsg, const char** ppReturn=0);

	/// send Messages test to the active view
	bool sendHasMsgToActiveView(const char* pMsg);
	/// Attach a view (get called by the FCView constructor)
	void attachView(Gui::BaseView* pcView);
	/// Detach a view (get called by the FCView destructor)
	void detachView(Gui::BaseView* pcView);
	/// get called if a view gets activated, this manage the whole activation scheme
	void viewActivated(MDIView* pcView);
	/// call update to all docuemnts an all views (costly!)
	void onUpdate(void);
	/// call update to all views of the active document
	void updateActive(void);
	//@}

public:


	static void initApplication();

	static void runApplication();

    static void initApplications();


	static void initTypes();


   void createStandardOperations();

   void tryClose( QCloseEvent * e );

	// ------------------------------ [2/13/2012 Administrator]

 	/// signal on activated workbench
  	boost::signal<void (const char*)> signalActivateWorkbench;
  	/// signal on added workbench
  	boost::signal<void (const char*)> signalAddWorkbench;
  	/// signal on removed workbench
  	boost::signal<void (const char*)> signalRemoveWorkbench;


	// ----------------------------- [2/13/2012 Administrator]


	boost::signal<void (const Gui::Gui_Document&)> signalNewDocument;
	/// signal on deleted Document
	boost::signal<void (const Gui::Gui_Document&)> signalDeleteDocument;
	/// signal on relabeling Document (user name)
	boost::signal<void (const Gui::Gui_Document&)> signalRelabelDocument;
	/// signal on renaming Document (internal name)
	boost::signal<void (const Gui::Gui_Document&)> signalRenameDocument;
	/// signal on activating Document
	boost::signal<void (const Gui::Gui_Document&)> signalActiveDocument;
	/// signal on saving Document
	boost::signal<void (const Gui::Gui_Document&)> signalSaveDocument;
	/// signal on restoring Document
	boost::signal<void (const Gui::Gui_Document&)> signalRestoreDocument;

	boost::signal<void (const Gui::ViewProvider&)> signalDeletedObject;
	/// signal on changed object property
	boost::signal<void (const Gui::ViewProvider&, const App::Property&)> signalChangedObject;

   	boost::signal<void (const Gui::Gui_Document&)> signalNewScene;


	void slotNewDocument(const App::Document&);
	void slotDeleteDocument(const App::Document&);
	void slotRelabelDocument(const App::Document&);
	void slotRenameDocument(const App::Document&);
	void slotActiveDocument(const App::Document&);

	void slotUpdataDoumentObject(const App::DocumentObject&);

	void slotNewScene(const App::Document&);
	void setActiveDocument(Gui::Gui_Document* pcDocument);
    Gui::Gui_Document* activeDocument(void) const;


	 void AddWorkbench(const std::string& name);
	 static void ActivateWorkbench(const char*);
	 void RemoveWorkbench(std::string& name)const;

	 // ------------------------------------ [2/16/2012 Administrator]

	 Gui::ViewProvider* getViewProvider(App::DocumentObject*) const;


	 CommandManager& commandManager(void);

	
	// Workbench* GetWorkbench(std::string& name)const;

	 static Gui_Application* GetInstance();

public:

	static Gui_Application* instance;

private:

	struct ApplicationP* d;



};


#endif